#include <stdio.h>
#include "mini2440.h"


/*
 * print the bit form of an integer
 * from the most significant bit to the little significant bit
 */
static inline
void bit_print_int (unsigned long a)
{
    int i;
    int n = sizeof(int) * 8;
    int mask = 1 << (n-1);

    for (i = 1; i <= n; i++) {
        putchar(((a & mask) == 0) ? '0' : '1');
        a <<= 1;
        if (i % 8 == 0) {
            putchar(' ');
        }
    }

    printf("\n");
}
    
static inline
void hex_print (char *des, void *start, int length)
{
    int i;
    unsigned char *p;

    printf(">>  %s [%d bytes]\n", des, length);

    p = (unsigned char*)start;
    for (i=0; i<length; i++) {
        if (i % 8 == 0) {
            if (i % 16 == 0) {
                if (i != 0) {
                    printf("\n");
                }
                printf("0x%08x:  ", (unsigned int)(p+i));
            } else {
                printf("  ");
            }
        }
        printf("%.2X ", *(p+i));
    }
    printf("\n");
}


void main (void)
{
    unsigned long rGPGCON = 0x0;
    unsigned long GPGCON = 0x0;
    //*
    rGPGCON = (rGPGCON & (~(0x03<<0*2 ))) | (0x02<<0*2);  //配置GPG0为EINT 8功能
    rGPGCON = (rGPGCON & (~(0x03<<3*2 ))) | (0x02<<3*2);  //配置GPG3为EINT11功能
    rGPGCON = (rGPGCON & (~(0x03<<5*2 ))) | (0x02<<5*2);  //配置GPG5为EINT13功能
    rGPGCON = (rGPGCON & (~(0x03<<6*2 ))) | (0x02<<6*2);  //配置GPG6为EINT14功能
    rGPGCON = (rGPGCON & (~(0x03<<7*2 ))) | (0x02<<7*2);  //配置GPG7为EINT15功能
    rGPGCON = (rGPGCON & (~(0x03<<11*2))) | (0x02<<11*2); //配置GPG11为EINT19功能

   // */
    GPGCON = SET_KEY_INTR(KEY0) | SET_KEY_INTR(KEY1) | SET_KEY_INTR(KEY2) | SET_KEY_INTR(KEY3) | SET_KEY_INTR(KEY4) | SET_KEY_INTR(KEY5);

    printf("0x%08x 0x%08x\n", rGPGCON, GPGCON);
    bit_print_int(rGPGCON);
    bit_print_int(GPGCON);
}
